package com.test.deencredit.bean_deencredit.userinfo_deencredit;

import android.content.Context;
import android.text.TextUtils;

import com.google.gson.Gson;
import com.test.deencredit.R;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;

public class LnAplyDetailInfo_deencredit {

    private static class Inner_deencredit {
        private static LnAplyDetailInfo_deencredit instance_deencredit = new LnAplyDetailInfo_deencredit();
    }

    private LnAplyDetailInfo_deencredit() {}

    public static LnAplyDetailInfo_deencredit getInstance_deencredit() {
        return Inner_deencredit.instance_deencredit;
    }

    public static void parse_deencredit(JSONObject obj) {
        Inner_deencredit.instance_deencredit = new Gson().fromJson(obj.toString(), LnAplyDetailInfo_deencredit.class);

        Inner_deencredit.instance_deencredit.detailItemList.clear();
        JSONArray param = obj.optJSONArray("detailItemList");
        Gson gson = new Gson();
        if (param!=null){
            for (int i=0;i<param.length();i++){
                try {
                    Inner_deencredit.instance_deencredit.detailItemList.add(gson.fromJson(param.optString(i), LnAplyItem_deencredit.class));
                }catch (Exception e){
                    e.printStackTrace();
                }
            }
        }

    }

    private String repayAmount;
    private String realAmount;
    private String processingVatFee;
    private String repayProVatFee;
    private String currency;
    private String repayProFee;
    private String bankAccount;//尼日、乌干达、肯尼亚
    private String overdueRate;
    private String interest;
    private String amount;
    private String processingFee;
    private String walletMobile;//加纳
    private String days;
    private String isShowWaitTips;//是否显示审核页提示文案
    private String waitTipsTitle;//审核页提示文案标题
    private String waitTipsText;//审核页提示文案内容
    //申请页显示配置信息
    private final ArrayList<LnAplyItem_deencredit> detailItemList = new ArrayList<>();

    public String getRpAmount_deencredit() {
        if (TextUtils.isEmpty(repayAmount)) return "";
        return repayAmount;
    }

    public String getRealAmount_deencredit() {
        if (TextUtils.isEmpty(realAmount)) return "";
        return realAmount;
    }

    public String getProcessingVatFee_deencredit() {
        if (TextUtils.isEmpty(processingVatFee)) return "";
        return processingVatFee;
    }

    public String getRpProVatFee_deencredit() {
        if (TextUtils.isEmpty(repayProVatFee)) return "";
        return repayProVatFee;
    }

    public String getCurrency_deencredit() {
        if (TextUtils.isEmpty(currency)) return "";
        return currency;
    }

    public String getRpProFee_deencredit() {
        if (TextUtils.isEmpty(repayProFee)) return "";
        return repayProFee;
    }

    public String getBkAccount_NiUgKe_deencredit() {
        if (TextUtils.isEmpty(bankAccount)) return "";
        return bankAccount;
    }

    public Double getOvduRate_deencredit() {

        if (TextUtils.isEmpty(overdueRate)) return 0d;

        try {
            return Double.parseDouble(overdueRate)*100;
        }catch (NumberFormatException e){
            e.printStackTrace();
            return 0d;
        }

    }

    public String getInterest_deencredit() {
        if (TextUtils.isEmpty(interest)) return "";
        return interest;
    }

    public String getAmount_deencredit() {
        if (TextUtils.isEmpty(amount)) return "";
        return amount;
    }

    public String getProcessingFee_deencredit() {
        if (TextUtils.isEmpty(processingFee)) return "";
        return processingFee;
    }

    public String getWltMobile_Gh_deencredit() {
        if (TextUtils.isEmpty(walletMobile)) return "";
        return walletMobile;
    }

    public String getDays_deencredit() {
        if (TextUtils.isEmpty(days)) return "";
        return days;
    }

    public String getTermStr_deencredit(Context context){

        try {
            int dayInt = Integer.parseInt(days);
            if (dayInt <= 1) return context.getString(R.string.day_deencredit,dayInt);
            else return context.getString(R.string.days_deencredit,dayInt);
        }catch (NumberFormatException e){
            e.printStackTrace();
            return context.getString(R.string.day_deencredit,0);
        }

    }

    public boolean isShowWaitTips_deencredit(){
        if (TextUtils.isEmpty(isShowWaitTips)) return false;
        return isShowWaitTips.equalsIgnoreCase("YES");
    }

    public String getWaitTipsTitle_deencredit() {
        if (TextUtils.isEmpty(waitTipsTitle)) return "";
        return waitTipsTitle;
    }

    public String getWaitTipsText_deencredit() {
        if (TextUtils.isEmpty(waitTipsText)) return "";
        return waitTipsText;
    }

    public ArrayList<LnAplyItem_deencredit> getDetailItemList_deencredit() {
        return detailItemList;
    }

}
